package com.ruoyi.bizsys.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bizsys.domain.SmsRecall;
import com.ruoyi.bizsys.service.ISmsRecallService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 召回短信Controller
 *
 * @author african-loan
 * @date 2021-12-30
 */
@RestController
@RequestMapping("/bizsys/sms_recall")
public class SmsRecallController extends BaseController {
    @Autowired
    private ISmsRecallService smsRecallService;

/**
 * 查询召回短信列表
 */
@PreAuthorize("@ss.hasPermi('bizsys:sms_recall:list')")
@GetMapping("/list")
        public TableDataInfo list(SmsRecall smsRecall) {
        startPage();
        List<SmsRecall> list = smsRecallService.selectSmsRecallList(smsRecall);
        return getDataTable(list);
    }
    
    /**
     * 导出召回短信列表
     */
    @PreAuthorize("@ss.hasPermi('bizsys:sms_recall:export')")
    @Log(title = "召回短信", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SmsRecall smsRecall) {
        List<SmsRecall> list = smsRecallService.selectSmsRecallList(smsRecall);
        ExcelUtil<SmsRecall> util = new ExcelUtil<SmsRecall>(SmsRecall.class);
        return util.exportExcel(list, "sms_recall");
    }

    /**
     * 获取召回短信详细信息
     */
    @PreAuthorize("@ss.hasPermi('bizsys:sms_recall:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(smsRecallService.selectSmsRecallById(id));
    }

    /**
     * 新增召回短信
     */
    @PreAuthorize("@ss.hasPermi('bizsys:sms_recall:add')")
    @Log(title = "召回短信", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SmsRecall smsRecall) {
        return toAjax(smsRecallService.insertSmsRecall(smsRecall));
    }

    /**
     * 修改召回短信
     */
    @PreAuthorize("@ss.hasPermi('bizsys:sms_recall:edit')")
    @Log(title = "召回短信", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SmsRecall smsRecall) {
        return toAjax(smsRecallService.updateSmsRecall(smsRecall));
    }

    /**
     * 删除召回短信
     */
    @PreAuthorize("@ss.hasPermi('bizsys:sms_recall:remove')")
    @Log(title = "召回短信", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(smsRecallService.deleteSmsRecallByIds(ids));
    }
}
